define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermoney/index',
                    add_url: 'usermoney/add',
                    // edit_url: 'usermoney/edit',
                    // del_url: 'usermoney/del',
                    multi_url: 'usermoney/multi',
                    table: 'user_money_log',
                }
            });

            var table = $("#table");
            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                $("#MoneyFeel").html(data.MoneyFeel);

            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'createtime',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'region_name', title: __('来源商家用户'),operate:false},
                        {field: 'region_name_play', title: __('来源支付用户'),operate:false},
                        {field: 'shoporder.shop_name', title: __('Shoporder.shop_name')},
                        {field: 'user.username', title: __('User.username')},
                        {field: 'money', title: __('Money'), operate:false},
                        {field: 'before', title: __('Before'), operate:false},
                        {field: 'after', title: __('After'), operate:false},
                        {field: 'money_type', title: __('Money_type'), searchList: {"0":__('Money_type 0'),"1":__('Money_type 1'),"2":__('Money_type 2'),"3":__('Money_type 3'),"4":__('Money_type 4'),"5":__('Money_type 5'),"6":__('Money_type 6'),"7":__('Money_type 7'),"8":__('Money_type 8'),"11":__('Money_type 11'),"13":__('Money_type 13')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'shoporder.order_no', title: __('Shoporder.order_no')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'memo', title: __('Memo'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        agent: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermoney/agent',
                    add_url: 'usermoney/add',
                    // edit_url: 'usermoney/edit',
                    // del_url: 'usermoney/del',
                    multi_url: 'usermoney/multi',
                    table: 'user_money_log',
                }
            });

            var table = $("#table");
            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                $("#MoneyFeel").html(data.MoneyFeel);

            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'createtime',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'region_name', title: __('来源用户'),operate:false},
                        {field: 'user.username', title: __('User.username')},
                        {field: 'money', title: __('Money'), operate:false},
                        {field: 'before', title: __('Before'), operate:false},
                        {field: 'after', title: __('After'), operate:false},
                        {field: 'money_type', title: __('Money_type'), searchList: {"0":__('Money_type 0'),"1":__('Money_type 1'),"2":__('Money_type 2'),"3":__('Money_type 3'),"4":__('Money_type 4'),"5":__('Money_type 5'),"6":__('Money_type 6'),"7":__('Money_type 7'),"8":__('Money_type 8'),"11":__('Money_type 11')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'memo', title: __('Memo'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        contvalue: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermoney/contValue',
                    add_url: 'usermoney/add',
                    // edit_url: 'usermoney/edit',
                    // del_url: 'usermoney/del',
                    multi_url: 'usermoney/multi',
                    table: 'user_money_log',
                }
            });

            var table = $("#table");
            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                $("#MoneyFeel").html(data.MoneyFeel);

            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',

                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'shoporder.shop_name', title: __('Shoporder.shop_name')},
                        {field: 'user.username', title: __('User.username')},
                        {field: 'money', title: '贡献值', operate:false},
                        {field: 'before', title: __('Before'), operate:false},
                        {field: 'after', title: __('After'), operate:false},
                        {field: 'money_type', title: __('Money_type'), searchList: {"0":__('Money_type 0'),"1":__('Money_type 1'),"2":__('Money_type 2'),"3":__('Money_type 3'),"4":__('Money_type 4'),"5":__('Money_type 5'),"6":__('Money_type 6'),"7":__('Money_type 7'),"8":__('Money_type 8')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'shoporder.order_no', title: __('Shoporder.order_no')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'memo', title: __('Memo'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        bonus: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermoney/bonus',
                    add_url: 'usermoney/add',
                    // edit_url: 'usermoney/edit',
                    // del_url: 'usermoney/del',
                    multi_url: 'usermoney/multi',
                    table: 'user_money_log',
                }
            });

            var table = $("#table");
            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                $("#MoneyFeel").html(data.MoneyFeel);

            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'createtime',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'shoporder.shop_name', title: __('Shoporder.shop_name')},
                        {field: 'user.username', title: __('User.username')},
                        {field: 'money', title: __('Money'), operate:false},
                        {field: 'before', title: __('Before'), operate:false},
                        {field: 'after', title: __('After'), operate:false},
                        {field: 'money_type', title: __('Money_type'), searchList: {"0":__('Money_type 0'),"1":__('Money_type 1'),"2":__('Money_type 2'),"3":__('Money_type 3'),"4":__('Money_type 4'),"5":__('Money_type 5'),"6":__('Money_type 6'),"7":__('Money_type 7'),"8":__('Money_type 8')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'shoporder.order_no', title: __('Shoporder.order_no')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'memo', title: __('Memo'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        stock: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermoney/stock',
                    add_url: 'usermoney/add',
                    // edit_url: 'usermoney/edit',
                    del_url: 'usermoney/del',
                    multi_url: 'usermoney/multi',
                    table: 'user_money_log',
                }
            });

            var table = $("#table");
            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                $("#MoneyFeel").html(data.MoneyFeel);

            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'createtime',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'shoporder.shop_name', title: __('Shoporder.shop_name')},
                        {field: 'user.username', title: __('User.username')},
                        {field: 'money', title: __('Money'), operate:false},
                        {field: 'before', title: __('Before'), operate:false},
                        {field: 'after', title: __('After'), operate:false},
                        {field: 'money_type', title: __('Money_type'), searchList: {"0":__('Money_type 0'),"1":__('Money_type 1'),"2":__('Money_type 2'),"3":__('Money_type 3'),"4":__('Money_type 4'),"5":__('Money_type 5'),"6":__('Money_type 6'),"7":__('Money_type 7'),"8":__('Money_type 8')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'shoporder.order_no', title: __('Shoporder.order_no')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'memo', title: __('Memo'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        deposit: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermoney/deposit',
                    add_url: 'usermoney/add',
                    // edit_url: 'usermoney/edit',
                    // del_url: 'usermoney/del',
                    multi_url: 'usermoney/multi',
                    table: 'user_money_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'createtime',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'shoporder.shop_name', title: __('Shoporder.shop_name')},
                        {field: 'user.username', title: __('User.username')},
                        {field: 'money', title: __('Money'), operate:false},
                        {field: 'before', title: __('Before'), operate:false},
                        {field: 'after', title: __('After'), operate:false},
                        {field: 'money_type', title: __('Money_type'), searchList: {"0":__('Money_type 0'),"1":__('Money_type 1'),"2":__('Money_type 2'),"3":__('Money_type 3'),"4":__('Money_type 4'),"5":__('Money_type 5'),"6":__('Money_type 6'),"7":__('Money_type 7'),"8":__('Money_type 8')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'shoporder.order_no', title: __('Shoporder.order_no')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'memo', title: __('Memo'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    } ;
    return Controller;
});